﻿using UltralightMarkup.Controllers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using System.Web.Mvc;
using System.Diagnostics;

namespace UltralightMarkup.Tests
{
    
    
    /// <summary>
    ///This is a test class for SubmitControllerTest and is intended
    ///to contain all SubmitControllerTest Unit Tests
    ///</summary>
	[TestClass]
	public class SubmitControllerTest
	{


		private TestContext testContextInstance;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion


		[TestMethod()]
		public void TestCode()
		{
			SubmitController target = new SubmitController();
			FormCollection collection = new FormCollection();
			
			collection.Add("comment", TestResource.TestCode);
			ViewResult actual = target.Index(collection) as ViewResult;
			Assert.AreEqual(TestResource.TestCodeExpected, actual.ViewData["Formatted"]);
		}


		[TestMethod()]
		public void TestBold()
		{
			SubmitController target = new SubmitController();
			FormCollection collection = new FormCollection();

			collection.Add("comment", TestResource.TestBold);
			ViewResult actual = target.Index(collection) as ViewResult;
			Assert.AreEqual(TestResource.TestBoldExpected, actual.ViewData["Formatted"]);
		}

		[TestMethod()]
		public void TestItalic()
		{
			SubmitController target = new SubmitController();
			FormCollection collection = new FormCollection();

			collection.Add("comment", TestResource.TestItalic);
			ViewResult actual = target.Index(collection) as ViewResult;
			Assert.AreEqual(TestResource.TestItalicExpected, actual.ViewData["Formatted"]);
		}

		[TestMethod()]
		public void TestLink()
		{
			SubmitController target = new SubmitController();
			FormCollection collection = new FormCollection();

			collection.Add("comment", TestResource.TestLink);
			ViewResult actual = target.Index(collection) as ViewResult;
			Assert.AreEqual(TestResource.TestLinkExpected, actual.ViewData["Formatted"]);
		}

		[TestMethod()]
		public void TestAll()
		{
			SubmitController target = new SubmitController();
			FormCollection collection = new FormCollection();

			collection.Add("comment", TestResource.TestAll);
			ViewResult actual = target.Index(collection) as ViewResult;
			Assert.AreEqual(TestResource.TestAllExpected, actual.ViewData["Formatted"]);
		}

		[TestMethod()]
		public void Benchmark()
		{
			var sw = new Stopwatch();
			sw.Start();
			var Transformer = new UltralightTransformer.Transform();
			for (int i = 0; i < 500; i++)
			{
				var a = Transformer.MakeHTML(TestResource.TestAll);
			}
			sw.Stop();
			
			Trace.Write(sw.ElapsedMilliseconds.ToString() + " ms");
			//Assert.IsTrue(1 == 1, sw.ElapsedMilliseconds.ToString() + " ms");
		}
	}
}
